#include "camerapage.h"
#include "cameraview.h"

#include <QDebug>
#include <QGroupBox>

CameraPage::CameraPage(QWidget *parent) :
	QScrollArea(parent)
{
	QWidget* mainWidget= new QWidget(this);
	m_MainLayout = new QGridLayout;
	mainWidget->setLayout(m_MainLayout);
	m_TmpWidgetList.reserve(9);
	for(int i = 0; i < 3; ++i)
		for(int j = 0; j < 3; ++j)
	{
		QGroupBox* tmp = new QGroupBox(this);
		tmp->setFixedSize(480,360+30);
		m_MainLayout->addWidget(tmp,i,j,1,1);
		m_TmpWidgetList.push_back(tmp);
	}
	setWidget(mainWidget);
}

bool CameraPage::setCameraView(int row, int col, CameraView* cameraView)
{
	if(row < 0 || row > 2||
	   col < 0 || col > 2)
	{
		qDebug()<<"Row or column value error";
		return false;
	}

	m_MainLayout->addWidget(cameraView, row, col, 1, 1);
	if(m_TmpWidgetList[row*3+col] != NULL)
	{
		delete m_TmpWidgetList[row*3+col];
		m_TmpWidgetList[row*3+col] = NULL;
	}
	return true;
}
